package de.dehuegel;

enum Alignment{
	TOP,DOWN,LEFT,RIGHT
}

public abstract class Tetramino {
	
	private boolean values[][];
	private Alignment alignment;
	private Point2D point;
	
	public Tetramino(Point2D point){
		this.point=point;
		this.alignment=Alignment.TOP;
		this.values=createNew(this.alignment);
	}
	
	abstract boolean[][] createNew(Alignment direction);

	public boolean[][] getValues() {
		return values;
	}

	public void setValues(boolean values[][]) {
		this.values = values;
	}

	public Alignment getDirection() {
		return alignment;
	}

	public void setDirection(Alignment direction) {
		this.alignment = direction;
	}

	public void rotate(){
		switch (getDirection()){
		case LEFT:
			this.setDirection(Alignment.DOWN);			
		case DOWN:
			this.setDirection(Alignment.RIGHT);
		case RIGHT:
			this.setDirection(Alignment.TOP);
		case TOP:
			this.setDirection(Alignment.LEFT);
		default:
			;
		}
		this.setValues(createNew(this.getDirection()));
	}
	protected boolean[][] getTransposedMatrix(boolean[][] matrix){
		boolean result[][]=new boolean[matrix[0].length][matrix.length];
		for(int i=0;i<matrix.length;i++){
			for(int j=0;j<matrix[0].length;j++){
				result[j][i]=matrix[i][j];
			}
		}
		return result;
	}

	public Point2D getPosition() {
		return point;
	}

	public void setPosition(Point2D position) {
		this.point = position;
	}
}
